//
//  PageView1.m
//  MagicCardTable2
//
//  Created by 向恒 on 15/6/1.
//  Copyright (c) 2015年 向恒. All rights reserved.
//

#import "CommonFunctionSettingsTableDetailsViewController.h"

@interface CommonFunctionSettingsTableDetailsViewController ()

@end

@implementation CommonFunctionSettingsTableDetailsViewController

@synthesize reflectMap;

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    reflectMap = [[CardMap alloc]init];
    
    //self.table.dataSource = self;
   // self.table.delegate = self;
//    self.table.tableHeaderView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"tableheader.png"]];
//    self.table.tableFooterView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"tableheader.png"]];
    //左滑退出详细页面
    UISwipeGestureRecognizer* gr = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(handleSwipeFrom:)];
    [gr setDirection:(UISwipeGestureRecognizerDirectionRight)];
    [[self view] addGestureRecognizer:gr];}

//- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
//#warning Potentially incomplete method implementation.
//    // Return the number of sections.
//    return 1;
//}
//手势响应函数
-(void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer
{
    if(recognizer.direction==UISwipeGestureRecognizerDirectionRight)
    {
        NSLog(@"gesture left ");
        //希望这里能够回到上一级
        //[self dismissModalViewControllerAnimated:TRUE];
        [self.navigationController popViewControllerAnimated:YES];
    }
}



-(UITableViewCell*) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString* cellId = @"cellId";
    UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:cellId];
    if(cell == nil)
    {
        cell = [[UITableViewCell alloc]
                initWithStyle:UITableViewCellStyleSubtitle
                reuseIdentifier:cellId];
    }
    cell.layer.cornerRadius = 12;
    cell.layer.masksToBounds = YES;
    NSUInteger rowNo = indexPath.row;
    cell.textLabel.text = [reflectMap.books objectAtIndex:rowNo];
//    cell.imageView.image = [UIImage imageNamed:@"ic_gray.png"];
//    cell.imageView.highlightedImage = [UIImage imageNamed:@"ic_hightlight.png"];
    cell.detailTextLabel.text = [reflectMap.details objectAtIndex:rowNo];
    return cell;
    
    
    
    
}


-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return  reflectMap.books.count;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
